package com.kstech.mp3604.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter4.BaseQuickAdapter
import com.kstech.mp3604.adapter.ControlInitConfigAdapter.VH
import com.kstech.mp3604.bean.ControlInitData
import com.kstech.mp3604.databinding.LayoutItemControlInitconfigBinding

class ControlInitConfigAdapter : BaseQuickAdapter<ControlInitData, VH>() {


    override fun onBindViewHolder(
        holder: VH, position: Int, item: ControlInitData?
    ) {
        holder.binding.apply {
            address.text = item!!.address
            index.text = item.sIndex.toString()
            name.text = item.name
            value.text = item.value.toString()
            unit.text = item.unit
        }
    }

    override fun onCreateViewHolder(
        context: Context, parent: ViewGroup, viewType: Int
    ): VH {
        return VH(parent)
    }

    class VH(
        val parent: ViewGroup,
        val binding: LayoutItemControlInitconfigBinding = LayoutItemControlInitconfigBinding.inflate(
            LayoutInflater.from(parent.context), parent, false
        ),
    ) : RecyclerView.ViewHolder(binding.root)

}
